//引入axios
import axios from 'axios'

//axios.defaults.baseURL = 'https://api.example.com';
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

export default (url,data,method = "post") => {
	//URLSearchParams
    let promise = new Promise(function(resolve, reject) {
        axios({
            method: method,
            url: url,
            data:data,
        }).then(function(res){
            resolve(res.data)
        }).catch(function(err){
            Message.error(err);
            reject(err)
        });
    })
    return promise
}